import Vue from 'vue'
import Vuex from 'vuex'
import createVuexAlong from "vuex-along";
Vue.use(Vuex)

const state = {
    canSearch:false,
    placeHolder:"请输入关键字",
    fileObj: {
        fileName: '',
        fileId: '',
    },
    theFile: {},
    nameList: [],
    moveNameList: [],
    nameTree: [],
    userDirId: '',
    searchInput: "",
    uploadUrlBox: {
        label: '',
        value: ''
    },
    ipfsArray:[],
    loadingList:[],
    outLoadingList:[],
    zlkLoadingList:[],
    groupLoadingList:[],
    lianLoadingList:[],
    portArray:[],
    uploadLoading:false,
    uploadPercent:0,
    uploadList:[],
    fileListDownBox:0,//文件详情大图标界面下载盒子　０：没有　１：大　２：小
    dataBaseDownBox:0,//文件详情大图标界面下载盒子　０：没有　１：大　２：小
    groupDownBox:0,//文件详情大图标界面下载盒子　０：没有　１：大　２：小
}

const mutations = {
    getUploadUrl(state, uploadUrlBox) {
        state.uploadUrlBox = {
            label: uploadUrlBox.label,
            value: uploadUrlBox.value
        };
    },
    setSearchInput(state, searchInput) {
        state.searchInput = searchInput;
    },
    getUserDirId(state, userDirId) {
        state.userDirId = userDirId
    },
    getTheFile(state, theFile) {
        state.theFile = theFile
    },
    fileInfo(state, fileObj) {
        state.fileObj = fileObj
    },
    //crumbs
    nameListPush(state, name) {
        state.nameList.push(name);
    },
    nameListPop(state) {
        state.nameList.pop();
    },
    clearNameList(state) {
        state.nameList = [];
    },
    moveNameListPush(state, name) {
        state.moveNameList.push(name);
    },
    moveNameListPop(state) {
        state.moveNameList.pop();
    },
    clearMoveNameList(state) {
        state.moveNameList = []
    },
    nameTreePush(state, name) {
        state.nameTree.push(name);
    },
    nameTreePop(state) {
        state.nameTree.pop();
    },
    nameTreeClear(state) {
        state.nameTree = []
    },
    nameTreeSet(state, name) {
        state.nameTree = name;
    },
    getIpfsArray(state,array){
        state.ipfsArray=array;
    },
    setLoadingList(state,array){
        state.loadingList=array;
    },
    setOutLoadingList(state,array){
        state.outLoadingList=array;
    },
    setZlkLoadingList(state,array){
        state.zlkLoadingList=array;
    },
    setGroupLoadingList(state,array){
        state.groupLoadingList=array;
    },
    setLianLoadingList(state,array){
        state.lianLoadingList=array;
    },
    setPortArray(state,array){
        state.portArray=array;
    },
    setUploadLoading(state,uploadBool){
      state.uploadLoading=uploadBool;
    },
    setUploadPercent(state,uploadPercent){
      state.uploadPercent=uploadPercent;
    },
    setUploadList(state,upArr){
      state.uploadList=upArr;
    },
    setFileListDownBox(state,tab){
        state.fileListDownBox=tab;
    },
    setDataBaseDownBox(state,tab){
        state.dataBaseDownBox=tab;
    },
    setGroupDownBox(state,tab){
        state.groupDownBox=tab;
    }
}

const actions = {
    incrementAsync({commit}) {

    }
}

export default new Vuex.Store({
    state,
    mutations,
    actions,
    plugins: [createVuexAlong({
        name: "hello-vuex-along", // 设置保存的集合名字，避免同站点下的多项目数据冲突
        local: {
            list: ["ma"],
            isFilter: true // 过滤模块 ma 数据， 将其他的存入 localStorage
        },
        session: {
            list: ["count", "ma.a1"] // 保存 count 和模块 ma 中的 a1 到 sessionStorage
        }
    })]
})
